package shared;

import java.io.IOException;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;

public class InitLog4j extends HttpServlet {
	
	private static final String logPath = "/WEB-INF/logs/error.log";
	
	public void init () {
		FileAppender appender = getAppender(logPath);
		if (appender == null) return;
		init
		
		
	}
	
	private FileAppender getAppender (String fileName){
		RollingFileAppender appender = null;
		try{
			appender = new RollingFileAppender(
					new PattenLayout("%-5p %c %t%n%29d - %m%n"),
					getServletContext().getRealPath(fileName),
					true);
			appender = setMaxBackupIndex(5);
			appender = setMaxFileSize("1MB");
		}
		catch{
			System.out.println("Could not create appender for " 
					+ fileName + )
					
		}
		return appender;
		
		
	}
	
	
}
